Fix code submission delays when the workspace viewer contains large number of objects#1713
Open
Fred-Wu wants to merge 2 commits into
Open
Fix code submission delays when the workspace viewer contains large number of objects#1713Fred-Wu wants to merge 2 commits into
Fred-Wu wants to merge 2 commits into
Conversation
…arge objects by delaying workspace inspection until after command submission. - Fixed nested expansion in the workspace viewer for lists, environments, pairlists, S4 objects, and data frames. - Improved workspace viewer performance by loading object items on demand. Expanding an object shows the first 500 items directly, and selecting the ellipsis row loads the next 500.
There was a problem hiding this comment.
Pull request overview
This PR addresses delays after code submission caused by eagerly inspecting/serializing large or deeply nested workspace objects in the active R session. It shifts the workspace viewer to a deferred + lazy-loading model and batches refresh requests so that newly submitted code can execute before workspace refresh work runs.
Changes:
- Debounce and coalesce workspace refresh requests (and defer refresh when submitting code).
- Return concise top-level workspace metadata and lazy-load nested object children on expansion, with pagination.
- Add a new
workspace_childrenrequest/handler path and adjust tests accordingly; remove now-obsolete inspection settings.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/workspaceViewer.ts | Adds lazy-loading of object children, paging support, and updates tree refresh/eventing behavior. |
| src/session.ts | Introduces debounced/coalesced workspace refresh scheduling and session-safety checks. |
| src/rTerminal.ts | Defers workspace refresh when sending code to the terminal to reduce perceived submission latency. |
| sess/R/server.R | Registers the new workspace_children request handler. |
| sess/R/handlers.R | Implements lightweight workspace summaries and paginated child enumeration for expandable objects. |
| src/test/suite/session.test.ts | Extends session communication tests to validate has_children and workspace_children. |
| package.json | Removes workspace inspection settings replaced by lazy loading. |
Comments suppressed due to low confidence (1)
src/rTerminal.ts:349
deferWorkspaceRefresh()is called beforechooseTerminal(). IfchooseTerminal()returnsundefined(no terminals / user cancels), this cancels a pending workspace refresh and it will not be rescheduled until the nextworkspace_updatednotification, leaving the workspace viewer stale. Move the call to after a terminal is successfully selected (right before sending text).
export async function runTextInTerm(text: string, execute: boolean = true): Promise<void> {
deferWorkspaceRefresh();
const term = await chooseTerminal();
if (term === undefined) {
return;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+141
to
+155
| const page = await this.getGlobalEnvChildren(element); | ||
| const items: TreeItem[] = page.children.map(child => | ||
| new GlobalEnvItem( | ||
| '', | ||
| child.class, | ||
| child.str.replace(/\s+/g, ' ').trim(), | ||
| child.type, | ||
| 0, | ||
| element.treeLevel + 1, | ||
| undefined, | ||
| child.has_children, | ||
| element.rootName, | ||
| child.selector ? [...element.objectPath, child.selector] : element.objectPath | ||
| ) | ||
| ); |
Comment on lines
+248
to
+256
| }) as { children?: unknown, next_start?: unknown } | undefined; | ||
| if (response && Array.isArray(response.children)) { | ||
| const children = response.children.filter((child): child is WorkspaceChild => | ||
| typeof child === 'object' && | ||
| child !== null && | ||
| 'str' in child && | ||
| 'type' in child && | ||
| 'has_children' in child | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is to fix code submission delays when the workspace viewer contains large, wide, or deeply nested objects.
After every command, the workspace viewer inspected objects in the global environment to build their details. Inspecting and serialising this information could take significant time for large objects. Because the inspection runs in the active R session, R could not process newly submitted code until the workspace refresh finished, which causes noticeable delay between code submission and execution.
Workspace refreshes now collect only concise top-level metadata. Refreshes are delayed briefly, and repeated refresh requests are combined into a single refresh, allowing newly submitted code to run first. Detailed object metadata is lazy-loaded when an object is expanded.
Changes
...loading the next page.r.session.objectLengthLimitr.session.objectTimeoutr.session.levelOfObjectDetail